import CryptoJS from 'crypto-js';

// key
const keys = 'YGTuYBSRqvMC3cJd';

export default {
    //加密
    encrypt(word) {
        var key = CryptoJS.enc.Utf8.parse(keys);
        var srcs = CryptoJS.enc.Utf8.parse(word);
        var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
        return encrypted.toString();
    },
    //解密
    decrypt(word) {
        var key = CryptoJS.enc.Utf8.parse(keys);
        var decrypt = CryptoJS.AES.decrypt(word, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
        return CryptoJS.enc.Utf8.stringify(decrypt).toString();
    }
}